package cn.itcast.bos.system.action;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.base.action.BaseAction;
import cn.itcast.bos.domain.security.Permission;
import cn.itcast.bos.system.service.PermissionService;

@Namespace("/")
@ParentPackage("json-default")
@Scope("prototype")
@Controller
public class PermissionAction extends BaseAction<Permission>{

	@Autowired
	private PermissionService permissionService;
	
	@Action(value="show_permission",results={@Result(name="success",type="json")})
	public String show(){
		List<Permission> permissions=permissionService.show();
		ServletActionContext.getContext().getValueStack().push(permissions);
		return SUCCESS;
	}
	
	@Action(value="add_permission")
	public String add(){
		permissionService.show(t);
		return NONE;
	}
	
}
